{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑菜单</h5>
                </div>
                <div class="ibox-content">
                    <form class="layui-form layui-form-pane" action="">
                        <input type="hidden" name="id" value="{$menu.id}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">菜单名称：</label>
                            <div class="layui-input-block">
                                <input id="title" type="text" class="layui-input" name="title" required="" aria-required="true" value="{$menu.title}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">节点：</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="name" value="{$menu.name}" placeholder="模块/控制器/方法"  class="layui-input" />
                                <span class="help-block m-b-none">如：admin/user/adduser </span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"> 样式名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="css" id="css" value="{$menu.css}" placeholder="输入样式名称"  class="layui-input" />
                                <span class="help-block m-b-none"> <a href="http://fontawesome.dashgame.com/" target="_black">选择图标</a> 如:fa fa-user</span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状&nbsp;态：</label>
                            <div class="layui-input-block">
                                    <input type="radio" name='status' value="1" title="开启" {if condition="$menu['status'] eq 1 "}checked{/if}/>&nbsp;&nbsp;
                                    <input type="radio" name='status' value="0" title="关闭" {if condition="$menu['status'] eq 0 "}checked{/if}/>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"> 排序：</label>
                            <div class="layui-input-block">
                                <input type="text" name="sort" id="sort" value="{$menu.sort}" placeholder="输入排序"  class="layui-input" />
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="btn btn-primary" type="submit" lay-submit lay-filter="edit_rule"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">

    $(function(){
        var form = layui.form;
        form.on('submit(edit_rule)',function (data) {
            var data = data.field;
            if( !data.title){
                layer.msg('请输入菜单名称',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }

            if( !data.name){
                layer.msg('控制器/方法不能为空',{icon:0,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
            $.post("{:url('edit_rule')}",data,function (result) {
                if(result.code==1){
                    layer.msg(result.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                        window.location.href="{:url('menu/index')}";
                    });
                }else{
                    layer.msg(result.msg, {icon: 6,time:1500,shade: 0.1});
                    return false;
                }
            });
            return false;
        });
    });

</script>
</body>
</html>